<template>
  <div>
    <div class="home-new">
      <div class="home-panel">
        <div class="container">
          <div class="head">
            <h3>新鲜好物<small>新鲜出炉 品质靠谱</small></h3>
            <a
              aria-current="page"
              href="#/"
              class="router-link-active router-link-exact-active xtx-more"
              ><span>查看全部</span><i class="iconfont icon-angle-right"></i
            ></a>
          </div>
          <div style="position: relative; height: 426px">
            <ul class="goods-list">
              <li v-for="(item, index) in arr1" :key="index" @click="clk(item.id)">
                <a href="javascript:;" class=""
                  ><img :src="item.picture" alt="" />
                  <p class="name" >{{ item.name }}</p>
                  <p class="desc" >{{ item.price }}</p></a
                >
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      arr1: [],
    };
  },
  mounted() {
    var _this = this;
    axios({
      url: "http://pcapi-xiaotuxian-front-devtest.itheima.net/home/new",
      mounted: "get",
    }).then(function (res) {
      if (res.data.msg == "操作成功") {
        _this.arr1 = res.data.result;
        console.log( _this.arr1);
      }
    });
  },
  methods:{
    clk(id){
      this.$router.push({path:'/produck/'+id,params:{id:id}})
    }
  }
};
</script>

<style scoped>
.ellipsis{
  color: #999;
  font-size: 18px !important;
}
.home-panel {
  background-color: #fff;
  width: 100%;
}
.home-panel .head {
  padding: 40px 0;
  display: flex;
  align-items: flex-end;
}
.home-panel .head h3 {
  flex: 1;
  font-size: 32px;
  font-weight: 400;
  margin-left: 6px;
  height: 35px;
  line-height: 35px;
}
.home-panel .head h3 small {
  font-size: 16px;
  color: #999;
  margin-left: 20px;
}
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
}
.goods-list li {
  width: 306px;
  height: 406px;
  transition: all 0.5s;
}

.goods-list li img {
  width: 306px;
  height: 306px;
}
.goods-list li p {
  font-size: 22px;
  padding: 12px 30px 0 30px;
  text-align: center;
}
.goods-list li .price {
  color: #cf4444;
}
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 426px;
}
.goods-list li {
  width: 306px;
  height: 406px;
  transition: all 0.5s;
  background: #f0f9f4;

}
.goods-list li:hover {
  transform: translate3d(0, -3px, 0);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.goods-list li img {
  width: 306px;
  height: 306px;
}
.goods-list li p {
  font-size: 22px;
  padding-top: 12px;
  text-align: center;
  font-size: 22px;
  padding: 12px 30px 0 30px;
  text-align: center;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.goods-list li .desc {
  color: #cf4444;
  font-size: 22px;
}
</style>